import request from '@/config/axios'

// 物料主数据 VO
export interface ProductMasterVO {
  id: string // 物料号
  categoryId: number // 类别号
  description: string // 物料描述
}

// 物料主数据 API
export const ProductMasterApi = {
  // 查询物料主数据分页
  getProductMasterPage: async (params: any) => {
    return await request.get({ url: `/manu/product-master/page`, params })
  },

  // 查询物料主数据详情
  getProductMaster: async (id: number) => {
    return await request.get({ url: `/manu/product-master/get?id=` + id })
  },

  // 新增物料主数据
  createProductMaster: async (data: ProductMasterVO) => {
    return await request.post({ url: `/manu/product-master/create`, data })
  },

  // 修改物料主数据
  updateProductMaster: async (data: ProductMasterVO) => {
    return await request.put({ url: `/manu/product-master/update`, data })
  },

  // 删除物料主数据
  deleteProductMaster: async (id: number) => {
    return await request.delete({ url: `/manu/product-master/delete?id=` + id })
  },

  // 导出物料主数据 Excel
  exportProductMaster: async (params) => {
    return await request.download({ url: `/manu/product-master/export-excel`, params })
  },

// ==================== 子表（物料bom） ====================

  // 获得物料bom分页
  getProductBomPage: async (params) => {
    return await request.get({ url: `/manu/product-master/product-bom/page`, params })
  },
  // 新增物料bom
  createProductBom: async (data) => {
    return await request.post({ url: `/manu/product-master/product-bom/create`, data })
  },

  // 修改物料bom
  updateProductBom: async (data) => {
    return await request.put({ url: `/manu/product-master/product-bom/update`, data })
  },

  // 删除物料bom
  deleteProductBom: async (id: number) => {
    return await request.delete({ url: `/manu/product-master/product-bom/delete?id=` + id })
  },

  // 获得物料bom
  getProductBom: async (id: number) => {
    return await request.get({ url: `/manu/product-master/product-bom/get?id=` + id })
  },

// ==================== 子表（物料特征值） ====================

  // 获得物料特征值分页
  getProductCharacterRecordPage: async (params) => {
    return await request.get({ url: `/manu/product-master/product-character-record/page`, params })
  },
  // 新增物料特征值
  createProductCharacterRecord: async (data) => {
    return await request.post({ url: `/manu/product-master/product-character-record/create`, data })
  },

  // 修改物料特征值
  updateProductCharacterRecord: async (data) => {
    return await request.put({ url: `/manu/product-master/product-character-record/update`, data })
  },

  // 删除物料特征值
  deleteProductCharacterRecord: async (id: number) => {
    return await request.delete({ url: `/manu/product-master/product-character-record/delete?id=` + id })
  },

  // 获得物料特征值
  getProductCharacterRecord: async (id: number) => {
    return await request.get({ url: `/manu/product-master/product-character-record/get?id=` + id })
  },
}
